<?php

namespace App\Transformers\Users;

use App\Models\UsersModel;
use League\Fractal\TransformerAbstract;

class ShowTransformer extends TransformerAbstract
{
    public function transform(UsersModel $users) {
        $school =   $users->school;
        $identity = $users->identity;
        $fans   =   $users->fans;
        $fansData = $users->getMemberCards($fans);
        return [
            'username'  =>  $users->username,
            'avatar'    =>  $users->avatar,
            'school'    =>  handleOne($school, 'school_name'),
            'identity'  =>  handleOne($identity, ['id','identity_name']),
            'user_account'  =>  $users->user_account,
            'customer'  => handleMany($fans, ['id', 'nickname', 'avatar', 'username', 'email']),
            'member_cards'  => $fansData,
            'fans_course' => $users->teacherInfo
//            'created_at' => currentDatetime($users->created_at),
//            'updated_at' => currentDatetime($users->updated_at),
        ];
    }

}